public class Item {
    private double price;
    private String name;
    private int number=1;

    @Override
    public String toString() {      //输出信息
        return "商品名："+name+"，单价："+price+"元"+"，买了"+number+"个";
    }
    public Item(){          //初始构造，可能用不着
        this.name="（未命名的商品）";
        this.price=0;
    }
    public Item(String name,double price,int number){       //各项数据齐全
        this.name=name;
        this.price=price;
        this.number=number;
    }

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }

    public int getNumber() {
        return number;
    }

    @Override
    public boolean equals(Object obj) {
        Item item= (Item) obj;
        return this.name.equals(item.name)&&this.price==item.price;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}
